/*global _ctxPath*/
import { useBaseInfoWithOut } from '@/store/modules/base-info';
import globalData from '@/plugins/data';
import globalMethods from '@/plugins/methods';

function transSupervision() {
  const transSupervisionDialog = globalMethods.dialog({
    id: 'transSupervisionDialog',
    title: $.i18n('选择督办类型'),
    url: _ctxPath + '/supervisionController.do?method=getSupervisionBindList&supType=0',
    width: 400,
    bodyStyle:'padding:0',
    centered: true,
    height: 200,
    targetWindow: window,
    transParams: {
      summaryId: globalData.summaryId,
      formId: useBaseInfoWithOut().businessData?.template?.formAppId
    },
    cancelText: $.i18n('intelli.doc.comparison.historyRecord.cancel'),
    okText: $.i18n('intelli.doc.comparison.historyRecord.confirm'),
    onCancel() {
      transSupervisionDialog.close();
    },
    onConfirm() {
      let rt = transSupervisionDialog.getValue();
      let supervisionUrl = `${_ctxPath}/collaboration/collaboration.do?method=newColl&transSupervision=1&templateId=${rt.templateId}`;
      window.openCtpWindow({"url": supervisionUrl});
      transSupervisionDialog.close();
    }
  });
}

export default function () {
  return new Promise((resolve) => {
    transSupervision.call(this);
    resolve();
  });
}
